﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

/*
   Copyright 2011 lotrodps@gmail.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

*/

namespace LOTRO_DPS_Parser
{
    public partial class TextResults : Form
    {
        public TextResults()
        {
            InitializeComponent();
        }

        string fullText;

        // Start setting up some public interfaces for local variables
        private int myDPS;
        public int MyDPS
        {
            get
            {
                return myDPS;
            }
            set
            {
                myDPS = value;
            }

        }

        private int theirDPS;
        public int TheirDPS
        {
            get
            {
                return theirDPS;
            }
            set
            {
                theirDPS = value;
            }
        }
                
        private int myAttacks;
        public int MyAttacks
        {
            get
            {
                return myAttacks;
            }
            set
            {
                myAttacks = value;
            }
        }

        private int theirAttacks;
        public int TheirAttacks
        {
            get
            {
                return theirAttacks;
            }
            set
            {
                theirAttacks = value;
            }
        }

        private decimal myDPA;
        public decimal MyDPA
        {
            get
            {
                return myDPA;
            }
            set
            {
                myDPA = value;
            }
        }

        private decimal theirDPA;
        public decimal TheirDPA
        {
            get
            {
                return theirDPA;
            }
            set
            {
                theirDPA = value;
            }
        }

        private string biggestHitOut;
        public string BiggestHitOut
        {
            get
            {
                return biggestHitOut;
            }
            set
            {
                biggestHitOut = value;
            }
        }

        private string biggestHitIn;
        public string BiggestHitIn
        {
            get
            {
                return biggestHitIn;
            }
            set
            {
                biggestHitIn = value;
            }
        }

        private int mySuccessfulAttacks;
        public int MySuccessfulAttacks
        {
            get
            {
                return mySuccessfulAttacks;
            }
            set
            {
                mySuccessfulAttacks = value;
            }
        }

        private int theirSuccessfulAttacks;
        public int TheirSuccessfulAttacks
        {
            get
            {
                return theirSuccessfulAttacks;
            }
            set
            {
                theirSuccessfulAttacks = value;
            }
        }

        private string myName;
        public string MyName
        {
            get
            {
                return myName;
            }
            set
            {
                myName = value;
            }
        }

        private string opponentName;
        public string OpponentName
        {
            get
            {
                return opponentName;
            }
            set
            {
                opponentName = value;
            }
        }

        private decimal theirAvoidResist;
        public decimal TheirAvoidResist
        {
            get
            {
                return theirAvoidResist;
            }
            set
            {
                theirAvoidResist = value;
            }
        }

        private decimal myAvoidResist;
        public decimal MyAvoidResist
        {
            get
            {
                return myAvoidResist;
            }
            set
            {
                myAvoidResist = value;
            }
        }

        private string bigHitTextIn;
        public string BigHitTextIn
        {
            get
            {
                return bigHitTextIn;
            }
            set
            {
                bigHitTextIn = value;
            }
        }

        private string bigHitTextOut;
        public string BigHitTextOut
        {
            get
            {
                return bigHitTextOut;
            }
            set
            {
                bigHitTextOut = value;
            }
        }

        private int myKBs;
        public int MyKBs
        {
            get
            {
                return myKBs;
            }
            set
            {
                myKBs = value;
            }
        }
        
        private List<string> myKills;
        public List<string> MyKills
        {
            get
            {
                return myKills;
            }
            set
            {
                myKills = value;
            }
        }

        private bool includeKBs;
        public bool IncludeKBs
        {
            get
            {
                return includeKBs;
            }
            set
            {
                includeKBs = value;
            }
        }

        private decimal myCritPct;
        public decimal MyCritPct
        {
            get
            {
                return myCritPct;
            }
            set
            {
                myCritPct = value;
            }
        }

        private decimal theirCritPct;
        public decimal TheirCritPct
        {
            get
            {
                return theirCritPct;
            }
            set
            {
                theirCritPct = value;
            }
        }

        private decimal myDevCritPct;
        public decimal MyDevCritPct
        {
            get
            {
                return myDevCritPct;
            }
            set
            {
                myDevCritPct = value;
            }
        }

        private decimal theirDevCritPct;
        public decimal TheirDevCritPct
        {
            get
            {
                return theirDevCritPct;
            }
            set
            {
                theirDevCritPct = value;
            }
        }

        private string pointsType;
        public string PointsType
        {
            get
            {
                return pointsType;
            }
            set
            {
                pointsType = value;
            }
        }

        private int points;
        public int Points
        {
            get
            {
                return points;
            }
            set
            {
                points = value;
            }
        }

        private decimal ppk;
        public decimal PPK
        {
            get
            {
                return ppk;
            }
            set
            {
                ppk = value;
            }
        }

        private void TextResults_Load(object sender, EventArgs e)
        {

            string resultsHeader;

            if (opponentName == "All")
            {
                resultsHeader = myName + " versus multiple opponents";
            }
            else
            {
                resultsHeader = myName + " versus " + opponentName;
            }

            string kbText = "";

            foreach (string n in myKills)
            {
                if (kbText == "")
                {
                    kbText = n;
                }
                else
                {
                    kbText = kbText + ", " + n;
                }
            }


            fullText = resultsHeader + Environment.NewLine
                + "------------------------------------------------------------" + Environment.NewLine
                + "Your total damage done was                           " + myDPS.ToString() + Environment.NewLine
                + "Total damage done to you was                         " + theirDPS.ToString() + Environment.NewLine
                + "Your average damage per attack was                   " + myDPA.ToString() + Environment.NewLine
                + "Average damage you took per attack was               " + theirDPA.ToString() + Environment.NewLine
                + "The largest hit you landed was for                   " + biggestHitOut.ToString() + Environment.NewLine
                + "The largest hit you took was for                     " + biggestHitIn.ToString() + Environment.NewLine
                + "Your total number of attempted attacks was           " + myAttacks.ToString() + Environment.NewLine
                + "Total number of attempted attacks against you was    " + theirAttacks.ToString() + Environment.NewLine
                + "Your number of successful attacks was                " + mySuccessfulAttacks.ToString() + Environment.NewLine
                + "Number of successful attacks against you was         " + theirSuccessfulAttacks.ToString() + Environment.NewLine
                + "Your combined avoidance/resistance was               " + myAvoidResist.ToString() + "%" + Environment.NewLine
                + "Opponents' combined avoidance/resistance was         " + theirAvoidResist.ToString() + "%" + Environment.NewLine
                + "Your critical percentage was                         " + myCritPct.ToString() + "%" + Environment.NewLine
                + "Opponents' critical percentage was                   " + theirCritPct.ToString() + "%" + Environment.NewLine
                + "Your devastating critical percentage was             " + myDevCritPct.ToString() + "%" + Environment.NewLine
                + "Opponents' devastating critical percentage was       " + theirDevCritPct.ToString() + "%" + Environment.NewLine
                + "Your total renown/infamy was                         " + points.ToString() + Environment.NewLine
                + "Your renown/infamy per kill was                      " + ppk.ToString() + Environment.NewLine
                + "------------------------------------------------------------" + Environment.NewLine
                + "Details of your biggest incoming attack:" + Environment.NewLine
                + bigHitTextIn + Environment.NewLine
                + Environment.NewLine
                + "Details of your biggest outgoing attack:" + Environment.NewLine
                + bigHitTextOut + Environment.NewLine;

            if (includeKBs == true && kbText != "")
            {
                fullText = fullText + Environment.NewLine
                + "You had killing blows on the following characters:" + Environment.NewLine
                + kbText;
            }

            resultsBox.Text = fullText;
        }

        private void closeButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ChooseFormat formatDialog = new ChooseFormat();
            formatDialog.InterfaceForIncomingText = fullText;
            formatDialog.ShowDialog();
        }
    }
}
